package com.itlaoqi.springcloud.memberservice.controller;

import com.itlaoqi.springcloud.memberservice.entity.Book;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@Controller
public class MemberController {
    @Resource
    private RestTemplate restTemplate;

    @GetMapping("/borrow")
    @ResponseBody
    public String borrow(String sn){
        Book book = restTemplate.getForObject("http://book-service/bsn?sn=" + sn, Book.class);
        return book.getName() + ":" + book.getDesc() + "图书借阅成功";
    }
}
